/*************************************************************************
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ************************************************************************/


/**
 * @file
 * SessionManager.h
 *
 * @author
 * Pavel Hasenohrl (<a href="mailto:hasenpav@fel.cvut.cz">hasenpav@fel.cvut.cz</a>)
 *
 * @brief
 * This header contains class which manages creations of sessions.
 */


#ifndef _SESSION_MANAGER_H
#define _SESSION_MANAGER_H

#include <list>
//#include <string>
#include "Config.h"
#include "PortManager.h"

class CSession;

/**
 * @brief
 * Class managing sessions.
 */
class CSessionManager {
  CConfig m_conf;
  CPortManager m_pman;
  int m_iSocket;
  //bool m_state;
  std::list<CSession *> m_lsSession;

  bool BindAndListen(unsigned short usPort);
  bool CreateSession(int iSocket);
 public:
  /**
   * @brief Initializes instance.
   * @param[in] usPort TCP port number the instance listen to
   * @param[in] szFile path to the config file
   * @return true if instance has been initialized successfully
   */
  bool Init(unsigned short usPort, const char *szFile);

  CSessionManager();
  ~CSessionManager();

  /**
   * @brief Does one iteration of listening process should be running in a cycle
   */
  void Run();
};

#endif

